<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        var str = prompt("请输入");
        {
            let reg = /^(ab)\d+/ ;          //以ab开始
            // let str = 'a1324465' ;
            // console.log(reg.test(str));     
        }
        {
            let reg = /^(ab)\w+(cd)$/ ;     //以ab开始，cd结尾，中间是字母数字下划线至少有一个的字符串
            // let str = 'ab___cd' ;
            // console.log(reg.test(str)); 
        }
        {
            let reg = /^[1-9]{1}[0-9]{4,10}(@qq\.com)$/ ; 
        }
        {
            let reg = /^[a-zA-Z0-9]+$/g; 
            console.log(str);
            console.log(reg.test(str));
        }
    </script>
</body>
</html>